﻿
//点击树节点执行方法
function TaskTreeNodeClick() {
   // debugger
    if (CPTreeGlobal_CurSelNodeData.NodeAttrEx == -1) return;
    var url = "/Plat/Business/BusinessEditLine?id=" + CPTreeGlobal_CurSelNodeData.NodeAttrEx;

    if (CPTreeGlobal_CurSelNodeData.NodeAttrEx == 1 || CPTreeGlobal_CurSelNodeData.NodeAttrEx == 0 || (CPTreeGlobal_CurSelNodeData.NodeAttrEx.split(',').length == 3 && CPTreeGlobal_CurSelNodeData.NodeAttrEx.split(',')[2] == "0"))
        url = "/Plat/Business/BusinessLine";
    CPTreeSetFrameUrl(url);
}

//debugger
var url = "/Plat/Business/BusinessLine";
CPTreeSetFrameUrl(url);



//删除选中节点
function OrderCPTreeDeleteNode() {
    debugger
    if (CPTreeGlobal_CurSelNodeData === null) {
        alert("请先选中待删除的节点！");
        return false;
    }
    var DeleteFieldValue = CPTreeGlobal_CurSelNodeData.DeleteFieldValue;
    if (DeleteFieldValue === "1" || DeleteFieldValue === "0") { alert("根基目录不能删除！"); return false; }
    if (DeleteFieldValue === "未设置") { alert("未创建任务不能删除！"); return false; }
    if (DeleteFieldValue.indexOf('未设置') > 0 && DeleteFieldValue.match(/[,，]/g).length === 2) { alert("未设置任务车辆不能删除！"); return false; }
    if (DeleteFieldValue.split(',').length == 3 || DeleteFieldValue.split(',').length == 4) { alert("请选择任务编号进行删除！"); return false; }
    if (confirm("您确实要删除选中节点及其子节点吗？")) {
       // debugger
        var delData = CPWebRootPath + "/api/OrderFormCable/DeleteTreeData";
        delData += "?pkFieldValue=" + CPTreeGlobal_CurSelNodeData.DeleteFieldValue;
        delData += "&CurUserId=" + CPCurUserId;
        delData += "&CurUserIden=" + CPCurUserIden;
        $.getJSON(delData, function (data) {
            if (data.Result == false) {
                alert(data.ErrorMsg);
                return false;
            }
            else {
                alert("删除成功！");
                window.location.reload();
                return;
            }
        });
    }
}